﻿Imports KurzCNB
Imports Alerts
Imports PHE

Partial Class Pages_ParamSystem
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim kurz As New KurzCNB
        Dim Poplatek As New PHE
        If Not Page.IsPostBack Then
            txb_kurz.Text = CStr(kurz.nactiUlozenyKurz("EUR"))
            txb_phe711.Text = CStr(Poplatek.nactiUlozenyPoplatek("PHE711"))
            txb_phe715.Text = CStr(Poplatek.nactiUlozenyPoplatek("PHE715"))
        End If

    End Sub

    Protected Sub btn_uloz_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_uloz.Click
        Dim retVal As Integer
        Dim kurz As New KurzCNB
        Dim alert As New Alerts

        retVal = kurz.ulozKurz("EUR", CSng(Replace(txb_kurz.Text, ".", ",")))
        If retVal = 0 Then alert.Show("Nová hodnota kurzu se nepodařila uložit do databáze. Napiš to Petrovi!", "Nastavení kurzu")
    End Sub

    Protected Sub btn_cnb_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_cnb.Click
        Dim retVal As Single
        Dim kurz As New KurzCNB
        Dim alert As New Alerts

        retVal = kurz.nactiAktualniKurz("EUR")

        alert.Show(String.Format("Dnešní kurz EURa z ČNB je : {0} Kč/1EUR", retVal), "Nastavení kurzu")
    End Sub

    Protected Sub btn_uloz_PHE711_Click(sender As Object, e As System.EventArgs) Handles btn_uloz_PHE711.Click
        Dim retVal As Integer
        Dim poplatek As New PHE
        Dim alert As New Alerts

        retVal = poplatek.ulozPoplatek("PHE711", CSng(Replace(txb_phe711.Text, ".", ",")))
        If retVal = 0 Then alert.Show("Nová hodnota PHE 7.1.1 se nepodařila uložit do databáze. Napiš to Petrovi!", "Nastavení PHE 7.1.1")
    End Sub

    Protected Sub btn_uloz_PHE715_Click(sender As Object, e As System.EventArgs) Handles btn_uloz_PHE715.Click
        Dim retVal As Integer
        Dim poplatek As New PHE
        Dim alert As New Alerts

        retVal = poplatek.ulozPoplatek("PHE715", CSng(Replace(txb_phe715.Text, ".", ",")))
        If retVal = 0 Then alert.Show("Nová hodnota PHE 7.1.5 se nepodařila uložit do databáze. Napiš to Petrovi!", "Nastavení PHE 7.1.5")

    End Sub
End Class
